import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '区域',
    dataIndex: 'area',
    width: 120,
  },
  {
    title: '创建人',
    dataIndex: 'userId',
    width: 120,
  },
  {
    title: '收货人',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '联系方式',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '详细地址',
    dataIndex: 'addressInfo',
    width: 120,
  },
  {
    title: '是否默认',
    dataIndex: 'defAddress',
    width: 120,
    customRender: ({ record }: Recordable) => {
      const isDefArray = [
        { label: '是', value: 1 },
        { label: '否', value: 2 },
      ];
      const isDef: any = isDefArray.find((item) => item.value == record.isDef);
      if (isDef) {
        return isDef.label;
      }
      return '';
    },
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 120,
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    width: 120,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 120,
  },
];

export const searchFormSchema: FormSchema[] = [];

export const formSchema: FormSchema[] = [
  {
    label: '主键',
    field: 'addressId',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    label: '用户Id',
    field: 'userId',
    component: 'Input',
    required: true,
    show: false,
  },
  {
    label: '区域',
    field: 'area',
    component: 'Input',
    required: true,
  },
  {
    label: '收货人',
    field: 'userName',
    component: 'Input',
    required: true,
  },
  {
    label: '联系方式',
    field: 'mobile',
    component: 'Input',
    required: true,
  },
  {
    label: '详细地址',
    field: 'addressInfo',
    component: 'Input',
    required: true,
  },
  {
    label: '默认地址',
    field: 'defAddress',
    component: 'RadioButtonGroup',
    required: true,
    defaultValue: 2,
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 2 },
      ],
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    required: true,
  },
];
